home *** CD-ROM | disk | FTP | other *** search
- /*
- st.c - Video and ST related function
-
- David Nash - dnash@chaos.demon.co.uk
- Graham Judd - gjudd@siward.demon.co.uk
- */
-
- /* $Id: ST.C,v 1.2 1994/02/05 18:50:32 gbj Exp user $ */
-
- /*
- $Log: ST.C,v $
- // Revision 1.2 1994/02/05 18:50:32 gbj
- // Beta release
- //
- // Revision 1.1 1994/01/30 17:25:46 gbj
- // Initial revision
- //
- // Revision 2.5 1994/01/30 00:31:58 gbj
- // Release 940130
- //
- // Revision 2.4 1994/01/23 03:54:26 gbj
- // Beta release.
- //
- // Revision 2.3 1994/01/23 03:50:00 gbj
- // Added missing v_clsvwk to v_init.
- //
- // Revision 2.2 1994/01/23 00:08:44 gbj
- // Added reverse video on/off when setting foreground/background colours.
- //
- // Revision 2.1 1994/01/22 16:20:18 gbj
- // First clean compile by GBJ
- //
- */
-
- #include <dos.h>
- #include <stdarg.h>
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <osbind.h>
- #include <aes.h> /* AES prototypes and defs */
- #include <vdi.h> /* VDI prototypes and defs */
-
- #include "screen.h"
- #include "st.h"
-
- short work_in[11] = {1,1,1,1,1,1,1,1,1,1,2}; /* v_opnvwk input array */
- short work_out[57]; /* v_opnvwk output array */
-
- short handle; /* virtual workstation handle */
- short junk; /* dummy variable */
-
- unsigned char scr_rows;
- unsigned char scr_cols;
- short ascr_rows; /* number of lines on screen */
- short ascr_cols; /* number of columns on screen */
-
- /* scr_attrib contains the required text attributes */
- static int scr_attrib = 0x07; /* black on white */
-
- /* Flag for Direct Video or Video Bios screen output */
- static int scr_direct = 0; /* 0 = Bios video, 1 = Direct video */
- /* 2 = Nick's black-on-white setup */
- /* preset to 0 to force initialise to use Bios */
-
- /* Cursor location for Direct Video */
- static unsigned scr_seg;
-
- short scr_x, scr_y; /* 0 to scr_cols-1, 0 to scr_rows-1 */
-
- /* Formatting buffer for printf */
- /* static char printf_text[50*80 + 1]; */ /* enough for a screenful at 50lines*80cols */
-
- /* set attributes */
-
- void textbackground(int newcolour)
- {
- scr_attrib = (scr_attrib & 0x07) | ((newcolour & 0x07) << 4);
- if (newcolour == BLACK)
- printf("\033q");
- else if (newcolour == LIGHTGRAY)
- printf("\033p");
- }
-
- void textcolor(int newcolour)
- {
- scr_attrib = (scr_attrib & 0xf0) | (newcolour & 0x0f);
- if (newcolour == BLACK)
- printf("\033q");
- else if (newcolour == LIGHTGRAY)
- printf("\033p");
- }
-
- /* clear to end: emit the aproppriate number
- * of spaces, without moving cursor.
- */
-
- void clreol(void)
- {
- printf("\033K"); /* Clear to EOL */
- }
-
- /* clear screen: clear all and set cursor home */
-
- void clrscr(void)
- {
- printf("\033E"); /* Clear screen and Home cursor */
- scr_x = scr_y = 0;
- }
-
- /* add line: scroll rest of screen down */
-
- void insline(void)
- {
- printf("\033L"); /* Add line, scroll scr down */
- }
-
- /* delete line: scroll rest up */
-
- void delline(void)
- {
- printf("\033M"); /* Del line, scroll scr up */
- }
-
- /* set cursor */
-
- void gotoxy(int x, int y)
- {
- printf("\033Y%c%c", y+31, x+31); /* Position cursor */
- scr_x = x-1;
- scr_y = y-1;
- }
-
- /* put character: set attribute first, then execute char.
- * Also remember if current line has changed.
- */
-
- int putch(int ch)
- {
- printf("%c", ch);
-
- switch (ch) {
- case '\r':
- break;
- case '\n':
- scr_x = 0;
- if (scr_y < scr_rows)
- scr_y++;
- break;
- default:
- if (scr_x < scr_cols)
- scr_x++;
- }
- return ch;
- }
-
- /* determine number of screen columns. Also set attrset according
- * to monochrome/color screen.
- */
-
- #if 0
- int v_cols(void)
- {
- return 80;
- }
-
- /* Get the number of rows
- */
-
- int v_rows(void)
- {
- return 25;
- }
- #endif
-
- #if 0
- /* Write a character to the screen */
-
- int cputs(const char *s)
- {
- while (*s)
- {
- putch(*s);
- s++;
- }
- return strlen(s);
- }
- #endif
-
- /* Scroll the screen up one line with start at the top */
-
- void scroll_up(int start)
-
- {
- int tem_y;
-
- tem_y = scr_y;
-
- gotoxy(1, start);
- delline();
- gotoxy(1, tem_y);
- }
-
-
- /*
- v_init() - initialise the video package
- use the vdi to find the number of rows & columns
- */
-
- void v_init(int directvideo)
- {
- appl_init(); /* start AES */
- handle=graf_handle(&junk, &junk, &junk, &junk); /* find AES handle */
- v_opnvwk(work_in, &handle, work_out); /* open workstation */
- vq_chcells(handle, &ascr_rows, &ascr_cols); /* get # rows and cols */
- v_clsvwk(handle); /* close workstation */
- appl_exit(); /* exit AES */
- scr_rows = (unsigned char)ascr_rows;
- scr_cols = (unsigned char)ascr_cols;
- #if 0
- scr_rows = v_rows() ;
- scr_cols = v_cols() ;
- #endif
- clrscr();
- }
-
- #if 0
- int farcoreleft(void)
- {
- /* return sizmem(); */
- /* return 500*1024; */
- return (int)Malloc(-1); /* based on coreleft() in ext.h */
- }
- #endif
-
- #if 0
- int findfirst(char name[], void *dta, short attrib)
- {
- Fsetdta(dta);
- return Fsfirst(name, attrib);
- }
- #endif
-